import Vue from 'vue'
import Vuex from 'vuex'
import {getLoginApi} from '../utlis/api/login/loginapi'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token:''
  },
  getters: {
  },
  mutations: {
    setlogin(state, token) {
      state.token = token
      localStorage.setItem('token',token)
    }
  },
  actions: {
    setLogin(context,userinfo) {
      return new Promise((resolve, reject) => {
        getLoginApi(userinfo).then((res) => {
          context.commit('setLogin',res.data.data.token)
          resolve(res)
        })
      })
    }
  },
  modules: {
  }
})
